Product Code Database
Example Keywords: gps -stitch $70-107
   » » Wiki: Dual Table
Tag Wiki 'Dual Table'.
Tag

DUAL table
 (

Rank: 100%
Bluestar Bluestar Bluestar Bluestar Blackstar
The DUAL table is a special one-row, one-column table present by default in and other database installations. In Oracle, the table has a single VARCHAR2(1) column called DUMMY that has a value of 'X'. It is suitable for use in selecting a pseudo column such as SYSDATE or USER.


Example use
Oracle's syntax requires the FROM clause but some queries don't require any tables - DUAL can be used in these cases.

SELECT 1+1 FROM dual;

SELECT 1 FROM dual;

SELECT USER FROM dual;

SELECT SYSDATE FROM dual;

SELECT * FROM dual;


History
explains why he created DUAL:

I created the DUAL table as an underlying object in the Oracle Data Dictionary. It was never meant to be seen itself, but instead used inside a view that was expected to be queried. The idea was that you could do a JOIN to the DUAL table and create two rows in the result for every one row in your table. Then, by using GROUP BY, the resulting join could be summarized to show the amount of storage for the DATA extent and for the INDEX extent(s). The name, DUAL, seemed apt for the process of creating a pair of rows from just one.


Optimization
Beginning with 10g Release 1, Oracle no longer performs physical or logical I/O on the DUAL table, though the table still exists. Oracle Database SQL Language Reference 11g Release 2 (11.2), Selecting from the DUAL Table

DUAL is readily available for all authorized users in a SQL database.


In other database systems
Several other databases (including Microsoft SQL Server, MySQL, PostgreSQL, SQLite, and Teradata) enable one to omit the FROM clause entirely if no table is needed. This avoids the need for any dummy table.


Notes
Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs
1s Time